import json
import re

def process_json_1(i):

    # 读取 JSON 文件
    file_path = fr"D:\subtitle\goods\walmart_goods_{i}.json"
    # file_path = r"D:\subtitle\goods\walmart_goods_25.json"

    with open(file_path, "r", encoding="utf-8") as f:
        data = f.read()
    data = data.replace("\\n", "")  # 用空格替换换行符
    # 去掉反斜杠和转义的双引号
    cleaned_data = data.replace('\\"', '').replace("\\", "")

    # 使用正则表达式替换 \" 为 ""
    data = re.sub(r'\\"', '', data)

    # 使用正则表达式替换 **文本内容** 为 [文本内容]
    cleaned_data = re.sub(r'\*\*(.*?)\*\*', r'[\1]', cleaned_data)

    # 使用正则表达式替换 [[文本内容]] 为 [文本内容]
    cleaned_data = re.sub(r'\[\[(.*?)\]\]', r'[\1]', cleaned_data)

    cleaned_data = data.replace("*", "")
    # 解析 JSON 确保格式正确
    json_data = json.loads(cleaned_data)

    # 重新写入 JSON 文件
    with open(file_path, "w", encoding="utf-8") as f:
        json.dump(json_data, f, ensure_ascii=False, indent=4)


